<template>
    <div @touchmove.prevent class="nav-list" :class="{'show':showMenu}">
        <ul class="class-ul">
            <li class="class-li" v-for="(item,index) in classList" :class="[{'active':index==curIndex}]" :key="item.type" @click="clickLiHandle(index)">
                <span class="span-name">{{item.name}}</span>
            </li>
        </ul>
    </div>
</template>
<script>
export default {
  name: "nv-Menu",
  props: {
    showMenu: {
      type: Boolean,
      default: false
    },
    classList: null
  },
  data() {
    return {
      curIndex: 0
    };
  },
  methods: {
    clickLiHandle(index) {
      if (this.curIndex == index) return;
      this.curIndex = index;
      this.$emit("changeClass", [this.curIndex]);
    }
  }
};
</script>

<style lang="stylus" rel="stylesheet/stylus">
// 侧边栏
.nav-list {
    position: fixed;
    top: .4rem;
    left: 0;
    width: 100%;
    background-color: #fff;
    transition: all 0.25s ease-out;
    z-index: 9;
    color: #313131;
    transform: translateY(-100%);

    &.show {
        transform: translateY(0);
    }

    .class-ul {
        width: 100%;
        padding: 0.06rem;
        box-sizing: border-box;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;

        .class-li {
            line-height: 0.3rem;
            margin: 0 0.1rem;
            display: inline-block;
            text-align: center;

            .span-name {
                font-size: 0.13rem;
            }

            &.active {
                color: #ff65a8;
            }
        }
    }
}
</style>